using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
namespace DAL
{
    public static class DataManagerConnection
    {
        //private static SqlConnection _connection = null;
        public static SqlConnection Connection
        {
            get
            {
                //if (_connection == null)
                //{
                //    _connection = new SqlConnection(
                //        ConfigurationManager.ConnectionStrings["DataManagerConnectionString"].ConnectionString
                //        );
                //}
                //return _connection;
                if (HttpContext.Current.Session["Connection"] == null)
                {
                    HttpContext.Current.Session["Connection"] = new SqlConnection(
                        ConfigurationManager.ConnectionStrings["DataManagerConnectionString"].ConnectionString
                        );
                }
                return HttpContext.Current.Session["Connection"] as SqlConnection;
            }
        }
    }
}